#pragma once
//============================================================================
// Copyright (C) 2013 Brett R. Jones
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================
#include "VxDefs.h"
#include "VxConnectId.h"
#include "VxSearchFlags.h"
#include "VxRelayFlags.h"

#pragma pack(push) 
#pragma pack(1)
class VxConnectInfo : public VxSearchFlags, public VxRelayFlags
{
public:
	//=== vars ===//
	U8					m_u8OnlineStatusFlags;					
	VxInetAddress		m_oUdpIp;								// Ip found from udp broadcast
	VxConnectId			m_oDirectConnectId;
	VxConnectId			m_oRelayConnectId;

	//=== constructor ==//
	VxConnectInfo();

	void			setMyOnlineId( U64 u64HiPart, U64 u64LoPart );
	OnlineId&		getMyOnlineId();
	void			getMyOnlineId( std::string& strRetId );
	U64				getMyOnlineIdLoPart();
	U64				getMyOnlineIdHiPart();

	OnlineId&		getRelayOnlineId();
	void			getRelayOnlineId( std::string& strRetId );
	U64				getRelayOnlineIdLoPart();
	U64				getRelayOnlineIdHiPart();
	U16				getRelayPort( void );

	//! get online ip address in dotted format
	void			getMyOnlineIPv4( std::string& strRetIp );
	void			getMyOnlineIPv6( std::string& strRetIp );
	VxIPv4Address	getMyOnlineIPv4( void );
	VxInetAddress	getMyOnlineIPv6( void );

	//! get ip based on if we can connect ipv6
	VxInetAddress	getOnlineIpAddress( void );
	//! get ip based on if we can connect ipv6
	VxInetAddress	getRelayIpAddress( void );
	//! get online ip address in binary format
	//VxInetAddress	getTcpIpAddress( void );

	//! set online ip address in binary format
	void	setOnlineIpAddress( VxInetAddress& oIp );
	void	setOnlineIpAddress( const char * pIp );

	//! get online port
	U16		getOnlinePort( void );
	//! get IP port as string
	void	getOnlinePort( std::string& strRetPort );
	//! set online port
	void	setOnlinePort( U16 u16Port );

	void		setIsOnline( bool bIsOnline );
	bool		isOnline( void );
	void		setIsNearby( bool bIsNearby );
	bool		isNearby( void );

	void		setIsFromSearchPkt( bool bIsFromSearch );
	bool		isFromSearchPkt( void );
	bool		hasValidRelay( void );
};

#pragma pack(pop)
